package com.active.web;

import com.active.service.AjaxPageResult;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.*;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2019/6/18 0018.
 */
@RestController
@Slf4j
@RequestMapping("mail")
public class MailController {

    @Resource(name = "taskService")
    private TaskService taskService;

    @Resource(name = "runtimeService")
    private RuntimeService runtimeService;

    @Resource(name = "repositoryService")
    private RepositoryService repositoryService;

    @Resource(name = "identityService")
    private IdentityService identityService;

    @Resource(name = "historyService")
    private HistoryService historyService;

    @Resource(name = "formService")
    private FormService formService;


    //邮件系统真的渣，不使用为好，用其他的，奶奶的，根本测试不下去
    @RequestMapping("test")
    public AjaxPageResult test(){
        log.info("测试邮件系统");

        Map<String,Object> map = new HashMap<>();

        map.put("to","1007060032@qq.com");
        map.put("from","lichuandong@yuhengkeji.com.cn");
        map.put("name","liyunlong");
        map.put("html","你就是个大傻子${name}");

        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("mailtest").singleResult();

        //运行邮件系统
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinition.getKey(),map);


        return AjaxPageResult.success("邮件系统运行成功");


    }
}
